#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long LL;
const LL MOD = 998244353;
const LL MAXN = 1e6+888;
LL inv[MAXN];
LL FastPOW(LL a, LL k) {
    LL ret = 1;
    while(k) {
        if (k&1) {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        k = (k >> 1);
    }
    return ret;
}
void Init() {
    inv[0] = 1;
    inv[1] = 1;
    for (LL i=2; i<MAXN; ++i) {
        inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    }
}


int main(int argc, char** argv) {
    Init();
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    int T;
    scanf("%d", &T);
    LL n, m;
    for (int cas = 1; cas <= T; ++cas) {
        scanf("%lld %lld", &n, &m);
        LL mMin = std::min(n, m);
        LL F = m % MOD;
        LL res = F;
        for (LL i=1; i<mMin; ++i) {
            LL t1 = (m - i) % MOD;
            LL t2 = (n - i) % MOD;
            F = F * t1 % MOD * t2 % MOD * inv[i] % MOD;
            res = (res + F) % MOD;
        }
        printf("Case #%d: %lld\n", cas, res);
    }
    return 0;
}
